﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace OnCommon
{
    internal class SocketAsyncEventArgsEx : SocketAsyncEventArgs
    {
        internal SocketAsyncEventArgsEx()
        {
            HasFirst = true;
            HasPacket = true;
        }
        /// <summary>
        /// 本次传输的数据包头
        /// </summary>
        internal Packet Packet { get; set; }

        /// <summary>
        /// 接收到的数据
        /// </summary>
        internal byte[] Data { get; set; }
        /// <summary>
        /// 已接收数据的长度
        /// </summary>
        internal int ReceiveLen { get; set; }

        /// <summary>
        /// 是否第一次接收数据
        /// </summary>
        internal bool HasFirst { get; set; }

        /// <summary>
        /// 是否包数据
        /// </summary>
        internal bool HasPacket { get; set; }

        /// <summary>
        /// 包头数据
        /// </summary>
        internal byte[] PacketData { get; set; }

        /// <summary>
        /// 包已接数据长度
        /// </summary>
        internal int PacketByteLen { get; set; }

        /// <summary>
        /// 一次包接收完毕，重置状态对象
        /// </summary>
        internal void ResetReceive()
        {
            this.ReceiveLen = 0;
            this.Data = null;

            this.PacketByteLen = 0;
            this.PacketData = null;

            this.HasFirst = true;
            this.HasPacket = true;

            this.Packet = default(Packet);

            this.FileName = null;
            this.FileNameLen = 0;
            this.FileNameByte = null;
            this.FileNameByteLen = 0;
            this.FileLenByte = null;
            this.FileLenByteLen = 0;
            this.SocketTcpFileData = null;
        }

        /// <summary>
        /// 文件名字长度
        /// </summary>
        public int FileNameLen { get; set; }

        /// <summary>
        /// 表示文件名字长度的字节
        /// </summary>
        public byte[] FileLenByte { get; set; }

        /// <summary>
        /// 表示文件名字长度的字节 已接收长度
        /// </summary>
        public int FileLenByteLen { get; set; }

        /// <summary>
        /// 文件名字节
        /// </summary>
        public byte[] FileNameByte { get; set; }
        /// <summary>
        /// 文件名字节 已接收长度
        /// </summary>
        public int FileNameByteLen { get; set; }

        public string FileName { get; set; }

        public SocketTcpFileData SocketTcpFileData { get; set; }
    }
}
